package com.itheima.service.impl;

import com.itheima.domain.User;
import com.itheima.mapper.UserMapper;
import com.itheima.service.UserService;
import com.itheima.utils.SqlSessionUtils;
import org.apache.ibatis.session.SqlSession;

public class UserServiceImpl implements UserService {


    @Override
    public User findByName(String name) {

        // 调用Dao查询, 代理方式实现
        SqlSession sqlSession = SqlSessionUtils.getSqlSession();

        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        User user = mapper.findByName(name);

        sqlSession.close();

        return user;
    }
}
